package com.example.demo.common;

import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;

public class Pagination implements Serializable {

    private static final long serialVersionUID = 1L;

    private Integer code;
    private String msg;
    private Integer page;
    private Integer limit;
    private Integer count;
    private Object data;

    Pagination() {}

    Pagination(HttpServletRequest request) {
        this.page = Integer.parseInt(request.getParameter("page"));
        this.limit = Integer.parseInt(request.getParameter("limit"));
    }

    public Pagination yes() {
        this.code = 0;
        this.msg = "成功";
        return this;
    }

    public Pagination no() {
        this.code = 1;
        this.msg = "失败";
        return this;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getLimit() {
        return limit;
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
